<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:replace="dashboard/header :: header"></head>

<body class="gray-bg">
	
	<link rel="stylesheet" th:href="@{/asserts/vendors/ztree/css/metroStyle/metroStyle.css}" type="text/css">
	
	<div class="container-div">
		<div class="row">
			 <div class="card col-lg-3">
			 	  <!-- 
			 	  <div class="card-body">
                   		<ul id="treeDemo" class="ztree"></ul>	
                  </div>
			 	  -->
                  
                  
                   <div class="box box-main  search-collapse">
						<div class="box-header">
							<div class="box-title">
								<i class="fa icon-grid"></i> 组织机构
							</div>
							<div class="box-tools pull-right">
								<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
								<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
								<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
							</div>
						</div>
						<div class="ui-layout-content">
							<ul id="treeDemo" class="ztree"></ul>	
						</div>
					</div>
				
             </div>
			 <div class="col-lg-9" style="float:left;">
				<div class="col-sm-12 search-collapse">
					<form id="operlog-form">
						<div class="select-list">
							<ul>
								<li>
									<label>系统模块： </label><input type="text" name="title"/>
								</li>
								<li>
									<label>操作人员： </label><input type="text" name="operName"/>
								</li>
								<li class="select-selectpicker">
									<label>操作类型： </label><select id="businessTypes" class="selectpicker" data-none-selected-text="请选择" multiple>
										<option value="1">新增</option>
										<option value="2">修改</option>
										<option value="3">删除</option>
										<option value="4">授权</option>
										<option value="5">导出</option>
										<option value="6">导入</option>
										<option value="7">强退</option>
										<option value="8">生成代码</option>
										<option value="9">清空数据</option>
									</select>
								</li>
								<li>
									<label>操作状态：</label><select name="status">
										<option value="">所有</option>
										<option value="0">成功</option>
										<option value="1">失败</option>
									</select>
								</li>
								<li class="select-time">
									<label>操作时间： </label>
									<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
									<span>-</span>
									<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
								</li>
								<li>
									<a class="btn btn-primary btn-rounded btn-sm" onclick="searchPre()"><i class="fa fa-search"></i>&nbsp;搜索</a>
									<a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
								</li>
							</ul>
						</div>
					</form>
				</div>
				
				<div class="btn-group-sm" id="toolbar" role="group">
					<a class="btn btn-success" onclick="$.operate.add()">
						<i class="fa fa-plus"></i> 新增
					</a>
					<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()">
			            <i class="fa fa-remove"></i> 删除
			        </a>
			        <a class="btn btn-danger" onclick="$.operate.clean()">
		                <i class="fa fa-trash"></i> 清空
		            </a>
		            <a class="btn btn-warning" onclick="$.table.exportExcel()">
			            <i class="fa fa-download"></i> 导出
			        </a>
		        </div>
		        
				<div class="col-sm-12 select-table table-striped">
					<table id="bootstrap-table" data-mobile-responsive="true"></table>
				</div>
				
			</div>
			
			
		</div>
	</div>
	
	<footer th:replace="dashboard/footer :: footer"></footer>
	
	<script type="text/javascript" th:src="@{/asserts/vendors/ztree/js/jquery.ztree.core.js}"></script>
	<script type="text/javascript" th:src="@{/asserts/vendors/ztree/js/jquery.ztree.excheck.js}"></script>
	<script type="text/javascript" th:src="@{/asserts/vendors/ztree/js/jquery.ztree.exedit.js}"></script>

	<script type="text/javascript">
        var setting = {
			async : {
				enable : true,
				type: "get",
				url: ctx+"boot/platform/department/departmentData?id=536478251871109120"
			},
            data: {
                simpleData: {
                	enable : true,
                	idKey : "id",
    				pIdKey : "pid",
                    enable: true 
                } , 
                key : {
    				name : "fullName"
    			}
            }  ,
			callback : {
				onClick : zTreeOnClick ,
				onAsyncSuccess : zTreeOnAsyncSuccess
			}
        };
       
        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting);
        });

        function zTreeOnClick(event, treeId, treeNode) {
    		console.log("tree node id = " + treeNode.id) ; 
    		$("input[id=pid]").val(treeNode.id) ;
			search() ; 
    	};

    	function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
    		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
    		var nodes = treeObj.getNodes();
    		for (var i = 0; i < nodes.length; i++) { //设置节点展开
    			treeObj.expandNode(nodes[i], true, true , true);
    		}
    	}
       
    </script>

	<script>
		var detailFlag = "";
		var datas = [{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u65B0\u589E\u64CD\u4F5C","params":{},"dictCode":16,"dictSort":1,"dictLabel":"\u65B0\u589E","dictValue":"1","dictType":"sys_oper_type","cssClass":"","listClass":"info","isDefault":"N","status":"0"},{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u4FEE\u6539\u64CD\u4F5C","params":{},"dictCode":17,"dictSort":2,"dictLabel":"\u4FEE\u6539","dictValue":"2","dictType":"sys_oper_type","cssClass":"","listClass":"info","isDefault":"N","status":"0"},{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u5220\u9664\u64CD\u4F5C","params":{},"dictCode":18,"dictSort":3,"dictLabel":"\u5220\u9664","dictValue":"3","dictType":"sys_oper_type","cssClass":"","listClass":"danger","isDefault":"N","status":"0"},{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u6388\u6743\u64CD\u4F5C","params":{},"dictCode":19,"dictSort":4,"dictLabel":"\u6388\u6743","dictValue":"4","dictType":"sys_oper_type","cssClass":"","listClass":"primary","isDefault":"N","status":"0"},{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u5BFC\u51FA\u64CD\u4F5C","params":{},"dictCode":20,"dictSort":5,"dictLabel":"\u5BFC\u51FA","dictValue":"5","dictType":"sys_oper_type","cssClass":"","listClass":"warning","isDefault":"N","status":"0"},{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u5BFC\u5165\u64CD\u4F5C","params":{},"dictCode":21,"dictSort":6,"dictLabel":"\u5BFC\u5165","dictValue":"6","dictType":"sys_oper_type","cssClass":"","listClass":"warning","isDefault":"N","status":"0"},{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u5F3A\u9000\u64CD\u4F5C","params":{},"dictCode":22,"dictSort":7,"dictLabel":"\u5F3A\u9000","dictValue":"7","dictType":"sys_oper_type","cssClass":"","listClass":"danger","isDefault":"N","status":"0"},{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u751F\u6210\u64CD\u4F5C","params":{},"dictCode":23,"dictSort":8,"dictLabel":"\u751F\u6210\u4EE3\u7801","dictValue":"8","dictType":"sys_oper_type","cssClass":"","listClass":"warning","isDefault":"N","status":"0"},{"searchValue":null,"createBy":"admin","createTime":"2018-03-16 03:33:00","updateBy":null,"updateTime":null,"remark":"\u6E05\u7A7A\u64CD\u4F5C","params":{},"dictCode":24,"dictSort":8,"dictLabel":"\u6E05\u7A7A\u6570\u636E","dictValue":"9","dictType":"sys_oper_type","cssClass":"","listClass":"danger","isDefault":"N","status":"0"}];
		var prefix = ctx + "monitor/operlog";

		$(function() {
		    var options = {
		        url: ctx+"boot/platform/department/datatables" ,
		        createUrl: ctx + 'boot/platform/department/add' ,
		        updateUrl: ctx+"boot/platform/department/modify?id={id}" ,
		        changeStatusUrl: ctx+"boot/platform/department/changeStatus?id={id}" , 
		        cleanUrl: prefix + "/clean",
		        detailUrl: ctx+"boot/platform/department/detail?id={id}",
		        removeUrl: ctx+"boot/platform/department/delete" ,
		        exportUrl: prefix + "/export",
		        sortName: "operTime",
		        uniqueId:"id" ,
		        sortOrder: "desc",
		        modalName: "操作日志",
		        escape: true,
		        showPageGo: true,
		        rememberSelected: true,
		        columns: [{field: 'state',checkbox: true },
		        	 
			        {field: 'applicationIdLabel', title: '所属应用'},
			        {field: 'fullName', title: '部门名称'},
			        {field: 'description', title: '部门描述'},
			        {field: 'hasStatusLabel', title: '状态', align: 'center',  formatter:function(value,row,index){ return $.table.status(value , row);}},
			        {field: 'addTime', title: '添加时间', sortable: true},
			        {field: 'id' , title: '操作',  align: 'center',  formatter: function(value, row, index) {
			                var actions = [];
			                
			                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
			                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
			                
			                return actions.join('');
			          }
			     }]
		    };
		    $.table.init(options);
		});
		
		function searchPre() {
		    var data = {};
		    data.businessTypes = $.common.join($('#businessTypes').selectpicker('val'));
		    $.table.search('operlog-form', data);
		}
		
		function resetPre() {
			$.form.reset();
			$("#businessTypes").selectpicker('refresh');
		}
	</script>
</body>
</html>